package com.student.liu.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.student.liu.entity.Cook;
import org.apache.ibatis.annotations.*;

/**
 * 用户类 Mapper
 */
@Mapper
public interface ICookMapper extends BaseMapper<Cook> {

    @Insert("insert into cook values(default,#{username},MD5(CONCAT(#{username},#{password})),#{nickname},#{sex},now(),#{usable})")
    @Options(
            keyProperty = "id",
            useGeneratedKeys = true
    )
    int insertCook(Cook cook);

    @Update("UPDATE cook SET `password` = MD5(CONCAT(username,#{password})) WHERE username = #{username};")
    int updateCook(Cook cook);


    @Select("SELECT COUNT(*) FROM `cook` where `password` =  MD5(CONCAT(#{username},#{password})) and username = #{username};")
    int getByIdSelectPassword(Cook cook);

//    @Select("SELECT * FROM cook ")
}
